package com.coolgor.coldot.schedule.Friday;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class StockTask {

    @Value("${schedule.Friday.stock}")
    private boolean OnOff;

    @Autowired
    StockService stockService;

//    @Scheduled(cron = "0/30 * * * * ?") // 测试
    public void trackStock() {
        if (OnOff) {
            if (stockService.isWorkday(new Date())) {
                stockService.trackStock();
            }
        }
    }
}
